<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="utf-8">
<title>滴答办公系统-班级列表</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet" href="media/layui/css/layui.css" media="all">
<script src="media/js/jquery.min.js"></script>

	<script type="text/javascript">
		function junpage(pageCount,pageSize) {
			var pagenum = $("#pagejun").val();
			var regex = /^[1-9]\d*$/;
			if (regex.test(pagenum)){
				if(pagenum>=1 && pagenum<=pageCount){
					location.href="/class_list?pageIndex="+pagenum+"&pageSize=" + pageSize;
				}else {
					alert("请输入一个范围内的数字")
				}
			}else {
				alert("请输入一个数学")
			}
		}
		function changePageSize(pageSize) {
			location.href="/class_list?pageIndex=1&pageSize=" + pageSize;
		}
	</script>
</head>
<body>
	<div class="layui-container">
		<table class="layui-table" id="tbdata" lay-filter="tbop">
			<thead>
				<tr>
					<td>序号</td>
					<td>班级名称</td>
					<td>班级人数</td>
					<td>学科名称</td>
					<td>周数</td>
					<td>位置</td>
					<td>开班日期</td>
					<td>操作</td>
				</tr>
			</thead>
			<tbody>
				<tr th:each="d:${pageUtils.records}" th:id="${d.id}">
					<td th:text="${d.id}">01</td>
					<td th:text="${d.class_Name}">JAVAEE0805</td>
					<td th:text="${d.studentcount}">50</td>
					<td th:text="${d.major.major_name}">JAVAEE</td>
					<td th:text="${d.class_Time}">30</td>
					<td th:text="${d.class_Address}">9教室</td>
					<td th:text="${d.class_Date}">2015-10-01</td>
					<td><a class="layui-btn layui-btn-mini" th:href="|/class_update/${d.id}|">编辑</a>
						<a class="layui-btn layui-btn-danger layui-btn-mini"
						lay-event="del" th:onclick="|deleteCourse(${d.id});|">删除</a></td>
				</tr>

			</tbody>
		</table>
		<div class="layui-box layui-laypage layui-laypage-default" id="layui-laypage-1">
								<a th:href="|/class_list?pageIndex=${pageUtils.pageIndex-1}&pageSize=${pageUtils.pageSize}|"
								   th:if="${pageUtils.pageIndex>1}" class="layui-laypage-prev " data-page="0">
									<i class="layui-icon">&lt;</i>
								</a>
								<!--							    <span style="color:#009688;font-weight: bold;">1</span>-->

								<a th:each="num:${pageUtils.numbers}" th:style="${pageUtils.pageIndex==num} ? 'color:#009688;font-weight: bold;':''" th:href="|/class_list?pageIndex=${num}&pageSize=${pageUtils.pageSize}|"  th:text="${num}"></a>
								<a th:href="|/class_list?pageIndex=${pageUtils.pageIndex+1}&pageSize=${pageUtils.pageSize}|"
								   th:if="${pageUtils.pageIndex<pageUtils.pageCount}" class="layui-laypage-next" data-page="2">
									<i class="layui-icon">&gt;</i>
								</a>
								<span class="layui-laypage-skip">到第
												   <input type="text" min="1" id="pagejun" th:value="${pageUtils.pageIndex}" class="layui-input">页
													<button type="button" class="layui-laypage-btn"
															th:onclick="|junpage(${pageUtils.pageCount},${pageUtils.pageSize})|">确定</button>
												</span>
								<span class="layui-laypage-count">当前[[${pageUtils.pageIndex}]]/[[${pageUtils.pageCount}]]页/[[${pageUtils.totalCount}]]条</span>
								<span class="layui-laypage-limits">
							    <select lay-ignore="" onchange="changePageSize(this.value)">
							        <option value="5" th:selected="${pageUtils.pageSize==5}">5 条/页</option>
									<option value="10" th:selected="${pageUtils.pageSize==10}">10 条/页</option>
									<option value="15" th:selected="${pageUtils.pageSize==15}">15 条/页</option>
							</select>
							</span>
						</div>
	</div>
	
	<script src="media/layui/layui.js"></script>
	
	<script type="text/javascript">
	   function deleteCourse(id){
		   layui.use('table', function() {
			   layer.confirm('是否确认删除班级?',function(index) {
			   	$.getJSON("/delete_class","id="+id, function (result) {
					if (result==true){
						layer.msg("删除成功", {icon : 6});
						window.location.reload()
					}else {
						layer.msg("删除失败", {icon : 5});
					}
				})

			   });
		   });
	   }
	</script>

</body>
</html>